
#include "StdAfx.h"

#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>

#include "PlayFab<%- gemName %>_<%- api.name %>SysComponent.h"

#include "PlayFabSettings.h"
#include "PlayFab<%- api.name %>Api.h"

namespace PlayFab<%- gemName %>Sdk
{
    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::Reflect(AZ::ReflectContext* context)
    {
        if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
        {
            serialize->Class<PlayFab<%- gemName %>_<%- api.name %>SysComponent, AZ::Component>()
                ->Version(0)
                ->SerializerForEmptyClass();

            if (AZ::EditContext* ec = serialize->GetEditContext())
            {
                ec->Class<PlayFab<%- gemName %>_<%- api.name %>SysComponent>("PlayFab<%- gemName %>_<%- api.name %>", "Provides access to the <%- api.name %> API within the PlayFab <%- gemName %> SDK")
                    ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
                    // ->Attribute(AZ::Edit::Attributes::Category, "") Set a category
                    ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
                    ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
                    ;
            }
        }
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
    {
        provided.push_back(AZ_CRC("PlayFab<%- gemName %>_<%- api.name %>Service"));
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
    {
        incompatible.push_back(AZ_CRC("PlayFab<%- gemName %>_<%- api.name %>Service"));
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
    {
        (void)required;
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
    {
        (void)dependent;
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::Init()
    {
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::Activate()
    {
        PlayFab<%- gemName %>_<%- api.name %>RequestBus::Handler::BusConnect();
    }

    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::Deactivate()
    {
        PlayFab<%- gemName %>_<%- api.name %>RequestBus::Handler::BusDisconnect();
    }

    int PlayFab<%- gemName %>_<%- api.name %>SysComponent::GetPendingCalls()
    {
        return PlayFabRequestManager::playFabHttp->GetPendingCalls();
    }
<% if (hasClientOptions) { %>
    // Client-Specific
    bool PlayFab<%- gemName %>_<%- api.name %>SysComponent::IsClientLoggedIn()
    {
        return PlayFabClientApi::IsClientLoggedIn();
    }
<% } %>
    // ------------ Generated API call wrappers
<% for(var i in api.calls) { var apiCall = api.calls[i];
%><% if(HasRequest(apiCall, api)) {
%>    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::<%- apiCall.name %>(<%- api.name %>Models::<%- apiCall.request %>& request, ProcessApiCallback<<%- api.name %>Models::<%- apiCall.result %>> callback, ErrorCallback errorCallback, void* customData)
    {
        PlayFab<%- api.name %>Api::<%- apiCall.name %>(request, callback, errorCallback, customData);
    }
<% } else {
%>    void PlayFab<%- gemName %>_<%- api.name %>SysComponent::<%- apiCall.name %>(ProcessApiCallback<<%- api.name %>Models::<%- apiCall.result %>> callback, ErrorCallback errorCallback, void* customData)
    {
        PlayFab<%- api.name %>Api::<%- apiCall.name %>(callback, errorCallback, customData);
    }
<% } } %>}
